<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            新产品库存监控
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">项目号</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请输入项目号" id="projectCode" value="" />
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">采购订单号</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请输入采购订单号" id="purchaseOrder" value="" />
                    </div>
                </div>
            </li>
        </ul>
        <div style="width:100%;margin-top:2%;"></div>
        <div class="aui-btn aui-btn-info aui-btn-block" onclick="doSearch()">查询</div>
        <!-- <div style="background-color:white;width: 100%;margin-top:2%;margin-bottom:20%; "> -->
            <!-- <table class="table"  id="table">
                <thead>
                    <tr
                        style="text-align: center;background-color: #DCE9F2;color: #467aa7;font-size: 12px;font-weight: bold;">
                        <td algin='center'>库位编码</td>
                        <td algin='center'>库位名称</td>
                        <td algin='center'>物料编码</td>
                        <td algin='center'>物料名称</td>
                        <td algin='center'>批次号</td>
                        <td algin='center'>数量</td>
                        <td algin='center'>项目号</td>
                        <td algin='center'>订单号</td>
                    </tr>
                </thead>
                <tbody id="tbodyHtml">
                </tbody>
            </table> -->
            <div
            style="background-color:white; width: 100%;margin-top:2%;overflow-x: auto;-webkit-overflow-scrolling:touch;">

            <table class="table" style='width:700px;' id="table1">
                <tbody style="table-layout:fixed">
                    <tr 
                        style="text-align: center;background-color: #DCE9F2;color: #467aa7;font-size: 15px;font-weight: bold;word-wrap:break-word;word-break:break-all;">
                        <td algin='center' style="width:70px;">项目号</td>
                        <td algin='center' style="width:70px;">订单号</td>
                        <td algin='center' style="width:90px;">库位名称</td>
                        <td algin='center' style="width:90px;">物料编码</td>
                        <td algin='center' style="width:90px;">物料名称</td>
                        <td algin='center' style="width:70px;">批次号</td>
                        <td algin='center' style="width:50px;">数量</td>
                       
                    </tr>
                </tbody>
            </table>
            <table class="table" style='width:700px;' id="table">
                <tbody id="tbodyHtml" style="table-layout:fixed; height: 450px;overflow-y: scroll;">
                </tbody>
            </table>
        </div>
           
        </div>
    </div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";

    //初始化
    apiready = function () {
        // $("#workCenterCode").focus();
        // idSelector = "workCenterCode";
        $("#projectCode").focus();
        idSelector = "workCellCode";
        doSearch()
    }

    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }




    //查询
    function doSearch() {
        var projectCode = $("#projectCode").val();
        var purchaseOrder = $("#purchaseOrder").val();
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getWmStockXcp";
        var data = {
            values: {
                projectCode: projectCode,
                purchaseOrder: purchaseOrder,
                appVersion: api.appVersion,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 30,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //返回成功
                if (myobj.code == "0") {
                    var list = eval(myobj.list);
                    var html = "";
                    for (var i = 0; i < list.length; i++) {
                        // html += "<tr style='text-align: center;color: black;font-size: 12px;background-color: #F5F5F5;'>";
                        // html += "<td name='workCellCode'>" + list[i].workCellCode + "</td>";
                        // html += "<td name='workCellName'>" + list[i].workCellName + "</td>";
                        // html += "<td name='mrlCode'>" + list[i].mrlCode + "</td>";
                        // html += "<td name='mrlName'>" + list[i].mrlName + "</td>";
                        // html += "<td name='lotCode'>" + list[i].lotCode + "</td>";
                        // html += "<td name='qty'>" + list[i].qty + "</td>";
                        // html += "<td name='projectCode'>" + list[i].projectCode + "</td>";
                        // html += "<td name='purchaseOrder'>" + list[i].purchaseOrder + "</td>";
                        // html += "</tr>";

                        html += "<tr style='word-wrap:break-word;word-break:break-all;text-align: center;color: black;font-size: 12px;background-color: #F5F5F5;'>";
                            html += "<td name='projectCode' style='width:70px;'>" + list[i].projectCode + "</td>";
                            html += "<td name='purchaseOrder' style='width:70px;'>" + list[i].purchaseOrder + "</td>";
                            html += "<td name='workCellName' style='width:90px;'>" + list[i].workCellName + "</td>";
                            html += "<td name='mrlCode' style='width:90px;'>" + list[i].mrlCode + "</td>";
                            html += "<td name='mrlName' style='width:90px;'>" + list[i].mrlName + "</td>";
                            html += "<td name='lotCode' style='width:70px;'>" + list[i].lotCode + "</td>";
                            html += "<td name='qty' style='width:50px;'>" + list[i].qty + "</td>";
                            
                            html += "</tr>";
                    }
                    $api.html($api.byId("tbodyHtml"), html);

                    //失败
                } else if (myobj.code == "1") {

                    //清空表格数据
                    $api.html($api.byId("tbodyHtml"), "");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }




    function closeDialog() {
        var dialogBox = api.require('dialogBox');
        dialogBox.close({
            dialogName: 'input'
        });
    }

    //订单返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>